package com.yq.light.notice.code.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class WebSocketComponent {

    @Autowired
    private SimpMessagingTemplate simpMessagingTemplate;

    @Scheduled(fixedRate = 1000*30)
    public void sendMessage(){
        log.info("服务器发送信息！！！");
        simpMessagingTemplate.convertAndSend("/topic/ip","这是一条由服务器主动推送的消息，并会持续推送！");
    }
}
